<!--
 * @Description: 站点质量参数
 * @Autor: wangwangwang
 * @Date: 2021-03-15 09:36:02
 * @LastEditors: wangwangwang
 * @LastEditTime: 2021-08-19 15:59:32
-->
<template>
  <div class="pages_content table">
    <el-container>
      <el-header>
        <breaDcrumb />
      </el-header>
      <el-main>
        <div class="tabtop">
          <div
            v-for="(item, index) in contractTypelist"
            :key="index"
            @click="choose(item.id)"
          >
            <div :class="currenindex == index ? 'active' : 'text'">
              {{ item.value }}
            </div>
            <div
              v-if="
                currenindex !== index &&
                  currenindex !== index + 1 &&
                  index !== 2
              "
              class="hr"
            ></div>
          </div>
        </div>
        <div v-if="currenindex !== 2" class="toptop" style>
          <div>
            <span v-if="UserInfo.adminStatus == 1">
              <span style="margin-right: 24px;">公司</span>
              <el-select
                ref="selection1"
                v-model="companyId"
                @change=";(leftitemId = ''), setstationIdlist()"
              >
                <el-option
                  v-for="item in companylist"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </span>
            <span style="margin-left: 24px;">
              <span style="margin-right: 24px;">站点</span>
              <el-select
                v-model="showsiteId"
                placeholder="请选择"
                @change="
                  change('siteId', 'showsiteId', showsiteId),
                    get_simple_organizationFun(showsiteId)
                "
              >
                <el-option
                  v-for="(item, index) in siteIdList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </span>
          </div>
          <el-button
            v-if="currenindex !== 0"
            size="small"
            class="bottom_all"
            @click="saveStation()"
            >保存</el-button
          >
        </div>
        <div v-show="currenindex !== 2" class="info" style="display: flex;">
          <div class="left">
            <!-- 左侧导航 -->
            <div class="nav">
              <template v-for="(item, index) in leftList">
                <div
                  :key="index"
                  :style="'width:' + 100 / leftList.length + '%'"
                  :class="item.value == showleftIndex ? 'left-active' : ''"
                  @click="change('leftIndex', 'showleftIndex', item.value)"
                >
                  {{ item.text }}
                </div>
              </template>
            </div>
            <!-- 数据 -->
            <!-- <div class="radio leftitem">
              <el-radio-group v-model="showleftitemId" @change="change('leftitemId', 'showleftitemId', showleftitemId)">
                <template v-for="(item, index) in leftitemList">
                  <div :key="index" class="radio-bg">
                    <el-radio :label="item.id">{{ item.name }}</el-radio>
                  </div>
                </template>
              </el-radio-group>
            </div> -->
            <div class="radio leftitem">
              <div style="padding:10px 0;">
                {{
                  ['', '原物料名称', '强度等级', '规范性能等级'][showleftIndex]
                }}:
              </div>
              <el-select
                v-model="showleftitemId"
                filterable
                placeholder="请选择"
                @change="changeRaw"
              >
                <el-option
                  v-for="(item, index) in leftitemList"
                  :key="index"
                  :label="item.name"
                  :value="item.name"
                ></el-option>
              </el-select>
              <div v-show="showleftIndex == 1">
                <div style="padding:10px 0;">
                  规格:
                </div>
                <el-select
                  v-model="specification"
                  filterable
                  placeholder="请选择"
                  @change="change('leftitemId', 'specification', specification)"
                >
                  <el-option v-for="item in specificationList" :key="item.specificationId" :label="item.specification" :value="item.specification"></el-option>
                </el-select>
              </div>
            </div>
          </div>
          <div class="center"></div>
          <!-- 检测频率设置 -->
          <div v-if="currenindex == 1" class="right" style="border:0">
            <div class="items">
              <div class="item">
                <div class="item-title">相关合同</div>
                <div class="radio">
                  <el-radio-group
                    v-model="showcontactId"
                    @change="
                      change('contactId', 'showcontactId', showcontactId)
                    "
                  >
                    <template v-for="(item, index) in contactIdist">
                      <div :key="index" class="radio-bg">
                        <el-radio
                          :label="item.contractId || item.engineeringId"
                          >{{ item.name }}</el-radio
                        >
                      </div>
                    </template>
                  </el-radio-group>
                </div>
              </div>
              <div v-if="leftIndex !== 3" class="item">
                <div class="item-title">检测类别</div>
                <div class="radio">
                  <el-radio-group
                    v-model="showleftId"
                    @change="change('leftId', 'showleftId', showleftId)"
                  >
                    <template v-for="(item, index) in leftIdList">
                      <div :key="index" class="radio-bg">
                        <el-radio :label="item.id">{{ item.name }}</el-radio>
                      </div>
                    </template>
                  </el-radio-group>
                </div>
              </div>
              <div v-if="leftIndex !== 1" class="item">
                <div class="item-title">检验前置条件</div>
                <div class="radio">
                  <div style="padding:10px 0 0 0">
                    <el-checkbox
                      v-model="orderStatus"
                      :true-label="1"
                      :false-label="0"
                      @change="changeLoading"
                    >
                      <div style="word-break:break-all;">
                        <div>订单计划量不小于</div>
                        <el-input
                          v-model="orderNum"
                          style="width:160px;margin:10px 0 0 0"
                          placeholder="请输入"
                          clearable
                          @change="changeLoading"
                        >
                          <span slot="suffix" style="line-height:36px">方</span>
                        </el-input>
                      </div>
                    </el-checkbox>
                  </div>
                  <div style="padding:20px 0 0 0">
                    <el-checkbox
                      v-model="productionStatus"
                      :true-label="1"
                      :false-label="0"
                      @change="changeLoading"
                    >
                      <div>单车生产量不小于</div>
                      <el-input
                        v-model="production"
                        style="width:160px;margin:10px 0 0 0"
                        placeholder="请输入"
                        clearable
                        @change="changeLoading"
                      >
                        <span slot="suffix" style="line-height:36px">方</span>
                      </el-input>
                    </el-checkbox>
                  </div>
                </div>
              </div>
              <div class="item">
                <div class="item-title">检测频率</div>
                <div class="radio">
                  <el-checkbox-group v-model="rightId" @change="changeLoading">
                    <template v-for="(item, index) in rightIdList">
                      <el-checkbox
                        v-if="
                          leftIndex == 1 ||
                            (leftIndex !== 1 && index !== 1 && index !== 2)
                        "
                        :key="index"
                        :label="item.id"
                        style="margin-bottom:10px;"
                      >
                        每<el-input-number
                          v-model="item.content"
                          :controls="false"
                          :precision="0"
                          style="width:80px;margin:0 10px;"
                          @change="changeLoading"
                        ></el-input-number>
                        {{ item.itemName }}
                      </el-checkbox>
                    </template>
                  </el-checkbox-group>
                  <template v-if="leftIndex !== 1">
                    <el-checkbox
                      v-model="IntervalState"
                      @change="changeLoading"
                    >
                      <div>累计生产量：</div>
                    </el-checkbox>
                    <template v-for="(item, index) in stateList">
                      <div :key="index">
                        <div
                          v-if="index == 0"
                          style="margin-top:20px;position: relative;"
                        >
                          <div class="text12">
                            <div>小于</div>
                            <el-input
                              v-model="item.topValue"
                              type="Number"
                              placeholder="请输入"
                              style="width:90px"
                              @change="changeLoading"
                            ></el-input>
                            <div>方</div>
                          </div>
                          <div class="text12">
                            <div>每</div>
                            <el-input
                              v-model="item.content"
                              style="width:90px"
                              type="Number"
                              placeholder="请输入"
                              clearable
                              @change="changeLoading"
                            ></el-input>
                            <div>方检验</div>
                          </div>
                        </div>
                        <div
                          v-else-if="index == stateList.length - 1"
                          style="margin-top:20px;position: relative;"
                        >
                          <div class="text12">
                            <div>大于</div>
                            <div v-show="false">
                              {{
                                (item.belowValue =
                                  stateList[index - 1].topValue)
                              }}
                            </div>
                            <el-input
                              v-model="item.topValue"
                              type="Number"
                              placeholder="请输入"
                              style="width:90px"
                              @change="
                                Number(item.topValue) <=
                                Number(stateList[index - 1].topValue)
                                  ? (item.topValue =
                                      Number(stateList[index - 1].topValue) + 1)
                                  : '',
                                  changeLoading
                              "
                            ></el-input>
                            <div>方</div>
                          </div>
                          <div class="text12">
                            <div>每</div>
                            <el-input
                              v-model="item.content"
                              style="width:90px"
                              type="Number"
                              placeholder="请输入"
                              clearable
                              @change="changeLoading"
                            ></el-input>
                            <div>方检验</div>
                          </div>
                          <div class="newbot">
                            <el-button
                              type="success"
                              circle
                              size="mini"
                              @click="addItem()"
                            >
                              <i
                                class="icon iconfont iconicon_button_add"
                                style="font-size:12px"
                              ></i>
                            </el-button>
                          </div>
                        </div>
                        <div
                          v-else
                          style="margin-top:20px; position: relative;"
                        >
                          <div class="text12">
                            <div>
                              <span style="padding-right:5px">
                                {{
                                  (item.belowValue =
                                    stateList[index - 1].topValue)
                                }}</span
                              >
                              至
                            </div>
                            <el-input
                              v-model="item.topValue"
                              type="Number"
                              placeholder="请输入"
                              style="width:90px"
                              @change="
                                Number(item.topValue) <=
                                Number(stateList[index - 1].topValue)
                                  ? (item.topValue =
                                      Number(stateList[index - 1].topValue) + 1)
                                  : '',
                                  changeLoading
                              "
                            ></el-input>
                            <div>方</div>
                          </div>
                          <div class="text12">
                            <div>每</div>
                            <el-input
                              v-model="item.content"
                              style="width:90px"
                              type="Number"
                              placeholder="请输入"
                              clearable
                              @change="changeLoading"
                            ></el-input>
                            <div>方检验</div>
                          </div>
                          <div class="newbot">
                            <div style="padding-top:5px">
                              <el-button
                                type="danger"
                                circle
                                size="mini"
                                @click="delItem(item, index)"
                              >
                                <i
                                  class="icon iconfont iconicon_button_delete"
                                  style="font-size:12px"
                                ></i>
                              </el-button>
                            </div>
                          </div>
                        </div>
                      </div>
                    </template>
                  </template>
                </div>
              </div>
            </div>
          </div>
          <!-- 验收标准 -->
          <div v-if="currenindex == 0" class="right">
            <!-- <div class="nav">
              <template v-for="(item, index) in categoryList">
                <div :key="index" :style="'width:' + 100 / categoryList.length + '%'" :class="item.id == rightIndex && categoryList.length > 1 ? 'left-active' : ''" @click="rightIndex=item.id">{{ item.name }}</div>
              </template>
            </div>
            <div style="padding: 20px 20px 0 20px;display: flex;justify-content: space-between;">
              <el-button size="mini" class="bottom_three" style="margin-left: 0;" @click="getnewtable()">获取公司标准</el-button>
              <el-button size="mini" class="bottom_all" style="margin-left: 0;" @click="addnbd()">保存</el-button>
            </div>
            <div v-loading="tableLoading" style="padding: 20px;height: calc(100% - 110px);">
              <el-table :header-cell-style="{ background: '#f3f6f9' }" :cell-style="{ borderRight: 'none' }" border stripe style="width:100%" :data="rightitemList" tooltip-effect="dark" height="100%">
                <template v-for="(item, index) in tablenav">
                  <el-table-column :key="index" :label="item.name" align="center" :width="index == 0 ? '120px' : 'auto'">
                    <template slot-scope="scope">
                      <span v-if="index == 0">{{ scope.row[index].name }}</span>
                      <div v-if="index !== 0 && scope.row[index]">
                        <el-select v-if="scope.row[index].type == 1" v-model="scope.row[index].name" placeholder="请选择" style="width:100%">
                          <el-option v-for="(item, index) in scope.row[index].list" :key="index" :label="item.name" :value="item.id"></el-option>
                        </el-select>
                        <el-input v-if="scope.row[index].type == 2" v-model="scope.row[index].name" style="width:100%" placeholder="请输入" clearable></el-input>
                        <span v-if="scope.row[index].type == 3">
                          <span>{{ scope.row[index].symbol }}</span>
                          <span v-if="scope.row[index].symbol.length==1">
                            <el-input v-model="scope.row[index].name" onmousewheel="return false;" type="Number" style="width: 90px;margin-left: 5px;" placeholder="请输入" clearable></el-input>
                          </span>
                          <span v-else>
                            <el-input v-model="scope.row[index].name" onmousewheel="return false;" style="width: 200px;margin-left: 5px;" placeholder="请输入两个数据并用逗号隔开" clearable></el-input>
                          </span>
                        </span>
                      </div>
                    </template>
                  </el-table-column>
                </template>
              </el-table>
            </div> -->
            <!-- 原物料检验（质量参数模板） -->
            <div class="nav">
              <div
                style="width: 50%"
                :class="{ 'left-active': rIndex === 0 }"
                @click="rIndex = 0"
              >
                原物料检验
              </div>
              <div
                style="width: 50%"
                :class="{ 'left-active': rIndex === 1 }"
                @click="rIndex = 1"
              >
                交工数据标准
              </div>
            </div>
            <QualityTemplate v-show="rIndex === 0" :templateIndex="selectTemplateIndex" :companyId="companyId" templateType="site" :config="qualityTemplateConfig" />
            <!-- 交工数据标准 -->
            <DueDataStandard v-show="rIndex === 1" :index="selectTemplateIndex" :config="qualityTemplateConfig" />
          </div>
        </div>
        <!-- 砼经时预警 -->
        <LabelLife v-if="currenindex == 2"></LabelLife>
      </el-main>
    </el-container>
    <!-- 公司验收方法 -->
    <el-dialog
      v-dialogDrag
      :visible.sync="Dialog"
      width="680px"
      :close-on-click-modal="false"
    >
      <span slot="title" class="dialog-title">公司验收方法</span>
      <div class="dialog-top">
        <span>
          <span>类型：</span>
          <span>{{ leftIndex == 1 ? '原物料' : '强度等级' }}</span>
        </span>
        <span style="margin-left: 48px;">
          <span>名称：</span>
          <span>{{ leftitemList | fromatTable(rawId, 'name', 'id') }}</span>
        </span>
        <span style="margin-left: 48px;">
          <span>规格：</span>
          <span>{{ specification }}</span>
        </span>
      </div>
      <el-table
        :header-cell-style="{ background: '#f3f6f9' }"
        :cell-style="{ borderRight: 'none' }"
        border
        stripe
        style="width:100%"
        :data="newrightitemList"
        tooltip-effect="dark"
        height="100%"
      >
        <template v-for="(item, index) in newtablenav">
          <el-table-column
            :key="index"
            :label="item.name"
            align="center"
            :width="index == 0 ? '120px' : 'auto'"
          >
            <template slot-scope="scope">
              <span v-if="index == 0">{{ scope.row[index] }}</span>
              <div v-if="index !== 0 && scope.row[index]">
                <span v-if="scope.row[index].type == 1">
                  <span>{{
                    scope.row[index].list
                      | fromatTable(scope.row[index].name, 'name', 'id')
                  }}</span>
                </span>
                <span v-if="scope.row[index].type == 2">
                  <span>{{ scope.row[index].name }}</span>
                </span>
                <span v-if="scope.row[index].type == 3">
                  <span>{{ scope.row[index].symbol }}</span>
                  <span>{{ scope.row[index].name }}</span>
                </span>
              </div>
            </template>
          </el-table-column>
        </template>
        <template v-if="signData">
          <el-table-column label="下限值" align="center" width="auto">
            <template slot-scope="scope"
              >{{ scope.row[1].lowerLimitValue }}
            </template>
          </el-table-column>
          <el-table-column label="上限值" align="center" width="auto">
            <template slot-scope="scope"
              >{{ scope.row[1].upperLimitValue }}
            </template>
          </el-table-column>
        </template>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button class="bottom_all_two" @click="Dialog = false"
          >取 消</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script src="./js/Sitequality.js"></script>
<style lang="scss" src="./css/Sitequality.scss" scoped></style>
